package o;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import com.huawei.appgallery.push.api.receiver.PushDealReceiver;
import com.huawei.appmarket.service.installresult.control.InstallerReceiver;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import java.util.ArrayList;
import java.util.List;
import o.cof.d;

public abstract class dsl {
    private static List<Class> ˏ = new ArrayList();

    static {
        ˋ(InstallerReceiver.class);
        ˋ(PushDealReceiver.class);
    }

    public static void ˋ(Class cls) {
        ˏ.add(cls);
    }

    public static void ॱ() {
        Logger.ˎ("ApkManager", "enableComponment");
        Context ˋ = ContentManager.getInstant().getContext();
        for (Class componentName : ˏ) {
            ˎ(new ComponentName(ˋ, componentName));
        }
    }

    public static void ˏ() {
        Logger.ˎ("ApkManager", "disableComponment");
        Context ˋ = ContentManager.getInstant().getContext();
        for (Class componentName : ˏ) {
            ॱ(new ComponentName(ˋ, componentName));
        }
    }

    private static void ॱ(ComponentName componentName) {
        ContentManager.getInstant().getContext().getPackageManager().setComponentEnabledSetting(componentName, 2, 1);
    }

    private static void ˎ(ComponentName componentName) {
        ContentManager.getInstant().getContext().getPackageManager().setComponentEnabledSetting(componentName, 0, 1);
    }

    public static void ˎ(SessionDownloadTask sessionDownloadTask, coc o_coc) {
        ˏ(sessionDownloadTask, o_coc, dwq.ˊ);
    }

    public static void ˏ(SessionDownloadTask sessionDownloadTask, coc o_coc, Handler handler) {
        int ˏ = etn.ˏ(sessionDownloadTask.ˊॱ());
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            cnw o_cnw = (cnw) ˋ.ॱ(cnw.class);
            if (o_cnw != null) {
                List<SplitTask> ᐝˊ = sessionDownloadTask.ᐝˊ();
                if (!CollectCheck.isEmpty((List) ᐝˊ)) {
                    d ॱ = new d().ˋ(sessionDownloadTask.ˊˊ()).ˏ(sessionDownloadTask.ॱᐝ()).ˊ(ˏ).ˊ(o_coc).ˏ((Object) sessionDownloadTask).ॱ(handler);
                    for (SplitTask splitTask : ᐝˊ) {
                        ॱ.ॱ(splitTask.ॱˊ(), splitTask.ॱᐝ(), splitTask.ᐝॱ());
                    }
                    o_cnw.ˋ(ContentManager.getInstant().getContext(), ॱ.ˎ());
                    return;
                }
                return;
            }
            Logger.e("ApkManager", "can not found IPackageInstaller Api");
            return;
        }
        Logger.e("ApkManager", "can not found PackageManager module");
    }

    public static void ˊ(String str, String str2, String str3, int i, coc o_coc) {
        int ˏ = etn.ˏ(i);
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            cnw o_cnw = (cnw) ˋ.ॱ(cnw.class);
            if (o_cnw != null) {
                Object ˏ2 = dsw.ˋ().ˏ(str);
                if (ˏ2 == null) {
                    ˏ2 = new cog(str, str2, str3);
                }
                o_cnw.ˊ(ContentManager.getInstant().getContext(), new d().ˋ(str).ˊ(ˏ).ˊ(o_coc).ˏ(ˏ2).ॱ(dwq.ˊ).ˎ());
                return;
            }
            Logger.e("ApkManager", "can not found IPackageInstaller Api");
            return;
        }
        Logger.e("ApkManager", "can not found PackageManager module");
    }

    public static boolean ˎ(String str) {
        String[] ˊ = ˊ(str);
        if (ˊ == null || ˊ.length <= 0) {
            return false;
        }
        return true;
    }

    public static String[] ˊ(String str) {
        List<SessionDownloadTask> ˏ = dvt.ˏ().ˏ(str);
        StringBuilder stringBuilder = new StringBuilder();
        try {
            if (!CollectCheck.isEmpty((List) ˏ)) {
                for (SessionDownloadTask sessionDownloadTask : ˏ) {
                    int ˌ = sessionDownloadTask.ˌ();
                    PackageManager packageManager = ContentManager.getInstant().getContext().getPackageManager();
                    int ॱᐝ = sessionDownloadTask.ॱᐝ();
                    int i = packageManager.getPackageInfo(str, DnsConfig.MAX_CACHE_ENTRIES).versionCode;
                    if (10 == ˌ || 9 == ˌ) {
                        if ((ॱᐝ < i ? 1 : null) != null) {
                            stringBuilder.append(sessionDownloadTask.ʾ()).append("-");
                        }
                    } else {
                        Object obj;
                        if (ॱᐝ > i || ॱᐝ == 0) {
                            obj = null;
                        } else {
                            obj = 1;
                        }
                        if (obj != null) {
                            stringBuilder.append(sessionDownloadTask.ʾ()).append("-");
                        } else {
                            continue;
                        }
                    }
                }
            }
        } catch (NameNotFoundException e) {
            Logger.ˋ("ApkManager", "not found: " + str);
        }
        if (stringBuilder.toString().trim().length() > 0) {
            return stringBuilder.toString().split("-");
        }
        return null;
    }
}
